﻿<%@ Page Language="C#" MasterPageFile="~/Member/MemMaster.master" AutoEventWireup="true"
    Inherits="PayRoller.Member.EmpAdd" CodeBehind="EmpAdd.aspx.cs" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolderTitle" Runat="Server">
    Add Employee
</asp:Content>
<%@ Register Src="../UControls/TXTFormatDate.ascx" TagName="TXTFormatDate" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <%@ register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="ajaxToolkit" %>
    <style type="text/css" rel="stylesheet">.modalBackground {
background-color:Gray;
filter:alpha(opacity=70);
opacity:0.7;}</style>
    <script type="text/javascript" language="javascript">
        function Check() {
            var vtxtEmpName = document.getElementById("ctl00_ContentPlaceHolder1_txtEmpName");
            var vtxtOrgEmpSid = document.getElementById("ctl00_ContentPlaceHolder1_txtOrgEmpSid");
            var vtxtTaxFileNumber = document.getElementById("ctl00_ContentPlaceHolder1_txtTaxFileNumber");
            var vtxtPayStartDate = document.getElementById("ctl00_ContentPlaceHolder1_txtPayStartDate");
            var vtxtPayFrequency = document.getElementById("ctl00_ContentPlaceHolder1_txtPayFrequency");

            if (vtxtEmpName.value.length == 0) {
                alert("Field 'Employee Name' is not valid!");
                vtxtEmpName.focus();
                return false;
            }
            if (vtxtOrgEmpSid.value.length == 0) {
                alert("Field 'Employee ID' is not valid!");
                vtxtOrgEmpSid.focus();
                return false;
            }
            if (vtxtTaxFileNumber.value.length == 0) {
                alert("Field 'Tax File Number' is not valid!");
                vtxtTaxFileNumber.focus();
                return false;
            }
            if (vtxtPayStartDate.value.length == 0) {
                alert("Field 'Payment Start Date' is not valid!");
                vtxtPayStartDate.focus();
                return false;
            }
            if (vtxtPayFrequency.value.length == 0) {
                alert("Field 'Pay Frequency' is not valid!");
                vtxtPayFrequency.focus();
                return false;
            }

            return true;
        }

        function Check1() {
            var vtxtEmpSid = document.getElementById("ctl00_ContentPlaceHolder1_txtEmpSid");
            var vtxtBankName = document.getElementById("ctl00_ContentPlaceHolder1_txtBankName");
            var vtxtBsb = document.getElementById("ctl00_ContentPlaceHolder1_txtBsb");
            var vtxtAccountNum = document.getElementById("ctl00_ContentPlaceHolder1_txtAccountNum");

            if (vtxtEmpSid.value.length == 0) {
                alert("Employee details must be entered (and save) before bank details!");
                return false;
            }
            if (vtxtBankName.value.length == 0) {
                alert("Field 'Bank Name' is not valid!");
                vtxtBankName.focus();
                return false;
            }
            if (vtxtBsb.value.length == 0) {
                alert("Field 'BSB' is not valid!");
                vtxtBsb.focus();
                return false;
            }
            if (vtxtAccountNum.value.length == 0) {
                alert("Field 'Account Num' is not valid!");
                vtxtAccountNum.focus();
                return false;
            }

            return true;
        }
    </script>
    <table width="570" border="0" cellspacing="1" cellpadding="1">
        <tr>
            <td height="22" colspan="2">
                Please enter employee details first.
            </td>
        </tr>
        <tr>
            <td height="22">
                Employee Name:
            </td>
            <td>
                <asp:TextBox ID="txtEmpName" runat="server" Width="200px"></asp:TextBox>
                <span class="styledot" style="color: #ff0000">*</span>
            </td>
        </tr>
        <tr>
            <td width="35%" height="22">
                Employee ID:
            </td>
            <td>
                <asp:TextBox ID="txtOrgEmpSid" runat="server" Width="200px"></asp:TextBox>
                <span class="styledot" style="color: #ff0000">*</span>
            </td>
        </tr>
        <tr>
            <td height="22">
                Tax File Number:
            </td>
            <td>
                <asp:TextBox ID="txtTaxFileNumber" runat="server" Width="200px"></asp:TextBox>
                <span class="styledot" style="color: #ff0000">*</span>
            </td>
        </tr>
        <tr>
            <td height="22">
                Next Payday:
            </td>
            <td>
                <uc1:TXTFormatDate ID="txtNextPayday" runat="server" />
                <span class="styledot" style="color: #ff0000">*</span>
            </td>
        </tr>
        <tr>
            <td height="22">
                Pay Frequency:
            </td>
            <td>
                <asp:TextBox ID="txtPayFrequency" runat="server" Width="200px"></asp:TextBox>
                <span class="styledot" style="color: #ff0000">*</span>
            </td>
        </tr>
        <tr>
            <td height="22">
                Address:
            </td>
            <td>
                <asp:TextBox ID="txtAddress1" runat="server" Width="200px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td height="22">
            </td>
            <td>
                <asp:TextBox ID="txtAddress2" runat="server" Width="200px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td height="22" colspan="2">
                <div align="center">
                    <asp:Button ID="Button1" runat="server" Text=" Save " OnClick="Button1_Click" Width="70px" />
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:Button ID="bnSelect" runat="server" Text="Add Bank" />&nbsp;
                    <input id="txtEmpSid" runat="server" style="width: 37px" type="hidden" />
                    <asp:Panel ID="Panel1" runat="server" Style="display: none;" CssClass="modalPopup"
                        Width="420">
                        <asp:Panel ID="Panel3" runat="server" Style="cursor: move; background-color: #ffffff;
                            border: solid 1px Gray; color: Black">
                            <div>
                                Bank Details:<br />
                            </div>
                        </asp:Panel>
                        <table width="100%" border="0" cellspacing="1" cellpadding="1" style="background-color:#ffffff">
                            <tr>
                                <td width="20%" height="22">
                                    <div align="left">
                                        Bank Name:</div>
                                </td>
                                <td style="width: 165px">
                                    <asp:TextBox ID="txtBankName" runat="server"></asp:TextBox>
                                </td>
                                <td width="20%">
                                    &nbsp;
                                </td>
                                <td width="30%">
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td height="22">
                                    <div align="left">
                                        Branch:</div>
                                </td>
                                <td style="width: 165px">
                                    <asp:TextBox ID="txtBranch" runat="server"></asp:TextBox>
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td height="22">
                                    <div align="left">
                                        Account Name:</div>
                                </td>
                                <td style="width: 165px">
                                    <asp:TextBox ID="txtAccountName" runat="server"></asp:TextBox>
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td height="22">
                                    <div align="left">
                                        BSB:</div>
                                </td>
                                <td style="width: 165px">
                                    <asp:TextBox ID="txtBsb" runat="server"></asp:TextBox>
                                </td>
                                <td>
                                    <div align="left">
                                        Account Number:</div>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtAccountNum" runat="server"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td style="height: 26px">
                                    <div align="left">
                                        Reference:</div>
                                </td>
                                <td style="height: 26px; width: 165px;">
                                    <asp:TextBox ID="txtPayReference" runat="server"></asp:TextBox>
                                </td>
                                <td style="height: 26px">
                                    &nbsp;
                                </td>
                                <td style="height: 26px">
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td height="22">
                                    &nbsp;
                                </td>
                                <td style="width: 165px">
                                    &nbsp;
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                                <td>
                                    &nbsp;
                                </td>
                            </tr>
                        </table>
                        <table width="100%" cellpadding="0" cellspacing="0" border="0" style="background-color:#ffffff">
                            <tr>
                                <td align="center" style="height: 24px">
                                    <asp:Button ID="Button2" runat="server" Text="OK" OnClick="Button2_Click" Width="60px" />
                                    &nbsp;&nbsp;&nbsp;&nbsp;
                                    <asp:Button ID="CancelButton" runat="server" Text="Cancel" Width="60px" />
                                    <div style="display: none">
                                        <asp:Button ID="Button3" runat="server" Text="" Height="0px" Width="0px" />
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                    <ajaxToolkit:modalpopupextender ID="ModalPopupExtender" runat="server" TargetControlID="bnSelect"
                        PopupControlID="Panel1" BackgroundCssClass="modalBackground" OkControlID="Button3"
                        OnOkScript="Check1()" CancelControlID="CancelButton" DropShadow="true" 
                        PopupDragHandleControlID="Panel3" />
                </div>
            </td>
        </tr>
        <tr>
            <td align="center" colspan="2">
                <table width="100%" border="0" cellspacing="1" cellpadding="1" bgcolor="#999999">
                    <tr bgcolor="#CCCCCC">
                        <td width="30%" height="22">
                            <div align="left">
                                Bank Name
                            </div>
                        </td>
                        <td width="30%">
                            <div align="left">
                                Account Name
                            </div>
                        </td>
                        <td>
                            <div align="left">
                                Reference</div>
                        </td>
                        <td align="center">
                            Delete
                        </td>
                    </tr>
                    <%		
                        for (int i = 0; i < dtBank.Rows.Count; i++)
                        {
                            string BankSid = dtBank.Rows[i]["Sid"].ToString();
                            string BankName = dtBank.Rows[i]["BankName"].ToString();
                            string AccountName = dtBank.Rows[i]["AccountName"].ToString();
                            string PayReference = dtBank.Rows[i]["PayReference"].ToString();
                    %>
                    <tr bgcolor="#FFFFFF">
                        <td height="22">
                            <div align="left">
                                <%=BankName%></div>
                        </td>
                        <td>
                            <div align="left">
                                <%=AccountName%></div>
                        </td>
                        <td>
                            <div align="left">
                                <%=PayReference%></div>
                        </td>
                        <td align="center">
                            <a href="EmpAdd.aspx?EmpSid=<%=txtEmpSid.Value%>&BankSid=<%=BankSid%>" onclick="return confirm('&#30830;&#23450;&#35201;&#21024;&#38500;&#35813;&#38134;&#34892;&#20449;&#24687;?');">
                                Delete</a>
                        </td>
                    </tr>
                    <%
                        }
                    %>
                </table>
            </td>
        </tr>
        <tr>
            <td colspan="2" height="10">
            </td>
        </tr>
        <tr>
            <td height="22" colspan="2">
                <div align="left">
                    <asp:Label ID="lblTip" runat="server"></asp:Label>
                </div>
            </td>
        </tr>
    </table>
    <script type="text/javascript">
        $(document).ready(function () {
            $("a[href='EmpAdd.aspx']").addClass("active");
        })
    </script>
</asp:Content>
